package com.mes.basicdata.domain;

import javax.persistence.Entity;
import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.GenericGenerators;
import org.springframework.context.annotation.Lazy;

import com.mes.common.domain.BasicModel;

@Entity()
@Table(name = "R_CALENDAR")
@BatchSize(size=30)
@Lazy(value=true)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Calendar extends BasicModel implements Serializable {
private static final long serialVersionUID = 1L;
	//日历唯一号
	@Id
	@GenericGenerator(name="calendarUid", strategy="assigned")
	@Column(name = "CAL_UID")
	protected String calendarUid;
	
	//日历名称
	@Column(name = "CAL_NAME")
	protected String calendarName;
	
	//是否基准日历
	@Column(name = "CAL_IS_BASE_CAL")
	protected Boolean isBase;
	
	//日历分组号
	@Column(name = "GROUPID")
	protected Long groupId;
	//日历分组名称
	@Column(name = "GROUPNAME")
	protected String groupName;
	
	//如果不是基准日历，则会有一个基准日历的唯一号，表示当前日历是基于哪个基准日历的
	@Column(name = "CAL_BASE_UID")
	protected String baseCalendarUid;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "CAL_BASE_UID",insertable=false,updatable=false)
	protected Calendar baseCalendar;
	
	//日历所属的部门
	@Column(name = "DEPTID")
	protected String deptUid;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "DEPTID",insertable = false, updatable = false)
	protected Dept dept;

	//日历对应的数据
	@OneToMany(fetch=FetchType.LAZY, mappedBy = "calendar")
	@OrderBy(value="dayOrException asc")
	protected Set<CalendarData> calendarDatas;
	
	/**
	 * 获取日历的唯一号
	 * @return
	 */
	@Deprecated
	public String getCalendarUid() {
		return this.calendarUid;
	}
	/**
	 * 设置日历的唯一号
	 * @param calendarUid
	 */
	@Deprecated
	public void setCalendarUid(String calendarUid) {
		this.calendarUid = calendarUid;
	}
	/**
	 * 获取日历的唯一号
	 * @return
	 */
	@Override
	public String getUuid() {
		return this.getCalendarUid();
	}
	/**
	 * 设置日历的唯一号
	 * @param uuid
	 */
	@Override
	public void setUuid(String uuid) {
		this.setCalendarUid(uuid);
	}
	/**
	 * 获取日历的名称
	 * @return
	 */
	public String getCalendarName() {
		return this.calendarName;
	}
	/**
	 * 设置日历的名称
	 * @param calendarName
	 */
	public void setCalendarName(String calendarName) {
		this.calendarName = calendarName;
	}
	/**
	 * 获取某个日历是否是基准日历
	 * @return
	 */
	public Boolean getIsBase() {
		return this.isBase;
	}
	/**
	 * 设置某个日历是否是基准日历
	 * @param isBase
	 */
	public void setIsBase(Boolean isBase) {
		this.isBase = isBase;
	}
	/**
	 * 获取日历的分组ID
	 * @return
	 */
	public Long getGroupId() {
		return this.groupId;
	}
	/**
	 * 设置日历的分组ID
	 * @param groupId
	 */
	public void setGroupId(Long groupId) {
		this.groupId = groupId;
	}
	/**
	 * 获取日历的分组名称
	 * @return
	 */
	public String getGroupName() {
		return this.groupName;
	}
	/**
	 * 设置日历的分组名称
	 * @param groupName
	 */
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	/**
	 * 获取日历的基准日历唯一号
	 * @return
	 */
	public String getBaseCalendarUid() {
		return this.baseCalendarUid;
	}
	/**
	 * 设置日历的基准日历唯一号
	 * @param baseCalendarUid
	 */
	public void setBaseCalendarUid(String baseCalendarUid) {
		this.baseCalendarUid = baseCalendarUid;
	}
	/**
	 * 获取日历的基准日历对象
	 * @return
	 */
	public Calendar getBaseCalendar() {
		return this.baseCalendar;
	}
	/**
	 * 设置日历的基准日历对象
	 * @param baseCalendar
	 */
	public void setBaseCalendar(Calendar baseCalendar) {
		this.baseCalendar = baseCalendar;
	}
	/**
	 * 获取日历所属的部门唯一号
	 * @return
	 */
	public String getDeptUid() {
		return this.deptUid;
	}
	/**
	 * 设置日历所属的部门唯一号
	 * @param deptUid
	 */
	public void setDeptUid(String deptUid) {
		this.deptUid = deptUid;
	}
	/**
	 * 获取日历所属部门对象
	 * @return
	 */
	public Dept getDept() {
		return this.dept;
	}
	/**
	 * 设置日历所属部门对象
	 * @param dept
	 */
	public void setDept(Dept dept) {
		this.dept = dept;
	}
	/**
	 * 获取日历的日历数据集合
	 * @return 
	 */
	public Set<CalendarData> getCalendarDatas() {
		return calendarDatas;
	}
	/**
	 * 设置日历的日历数据集合
	 * @param calendarDatas
	 */
	public void setCalendarDatas(Set<CalendarData> calendarDatas) {
		this.calendarDatas = calendarDatas;
	}
	

}
